using System;
using System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;

namespace Kaleida.ServiceMonitor.Model.StructuredSource
{
    public class ActionDefinition
    {
        private static readonly ActionDefinition doNothing = new ActionDefinition("do-nothing");

        private readonly string name;
        private readonly IList<string> arguments;

        public static ActionDefinition DoNothing
        {
            get { return doNothing; }
        }

        public ActionDefinition(string name) : this(name, new string[0])
        {
        }

        public ActionDefinition([NotNull] string name, [NotNull] IList<string> arguments)
        {
            if (name == null) throw new ArgumentNullException("name");
            if (arguments == null) throw new ArgumentNullException("arguments");

            this.name = name;
            this.arguments = arguments;
        }

        [NotNull]
        public string Name
        {
            get { return name; }
        }

        public IList<string> Arguments
        {
            get { return arguments; }
        }

        public override string ToString()
        {
            return string.Format("{0} ({1})", name, string.Join(", ", arguments.Select(i => "'" + i + "'")));
        }
    }
}